<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>各类型新闻数量统计</title>
    <!-- 引入 echarts.js 这里使用flask的url_for-->
    <script src="{{ url_for('static', filename='js/echarts.js') }}"></script>
    <style>
        .first div {
            float: left;
            padding-left: 100px;
        }

        #pie {
            margin-left: 30%;
            margin-right: 30%;
        }
    </style>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<h2 align="center">各类型新闻数量统计</h2>
<div class="first">
    <div id="bar" style="width: 600px;height:400px;"></div>
    <div id="line" style="width: 600px;height:400px;"></div>
</div>
<div id="pie" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChartBar = echarts.init(document.getElementById('bar'));
    var myChartLine = echarts.init(document.getElementById('line'));
    var myChartPie = echarts.init(document.getElementById('pie'));
    // 指定图表的配置项和数据
    var option1 = {
        tooltip: {},
        legend: {
            data: ['数量/个']
        },
        toolbox: {
        },
        xAxis: {
            data:{{ type_list | safe }}
        },
        yAxis: {},
        series: [{
            name: '数量/个',
            type: 'bar',
            data:{{ new_count_list | safe }}
        }]
    };
    var option2 = {
        tooltip: {},
        legend: {
            data: ['数量/个']
        },
        xAxis: {
            data:{{ type_list | safe }}
        },
        yAxis: {},
        series: [{
            name: '数量/个',
            type: 'line',
            data:{{ new_count_list | safe }}
        }]
    };
    var option3 = {
        tooltip: {},
        legend: {
            orient: 'vertical',
            x: 'left',
            data:{{ type_list | safe }}
        },
        toolbox: {
            show: true,
            feature: {
                mark: {show: true},
                dataView: {show: true, readOnly: false},
                magicType: {
                    show: true,
                    type: ['pie', 'funnel'],
                    option: {
                        funnel: {
                            x: '25%',
                            width: '50%',
                            funnelAlign: 'left',
                            max: 1548
                        }
                    }
                },
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        calculable: true,
        series: [
            {
                name: '新闻种类',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data:{{ result_list | safe }}
            }
        ]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartBar.setOption(option1);
    myChartLine.setOption(option2);
    myChartPie.setOption(option3);
</script>
</body>
</html>
